package com.atguigu.yygh.user.util;/*
 * @author: XueYouPeng
 * @time: 2023/6/15 10:15
 */

import com.atguigu.utils.JwtHelper;

import javax.servlet.http.HttpServletRequest;

public class AuthContextHolder {

    public static Long getUserId(HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }

    public static String getUserName(HttpServletRequest request){
        //从header中获取token
        String token = request.getHeader("token");
        //jwt从token中获取userid
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}
